/*
 *  fftw.h
 *  phaseit3d
 *
 *  Created by Anton Barty on 26/07/11.
 *  Copyright 2011 Anton Barty. All rights reserved.
 *
 */
#include <fftw3.h>
#include <math.h>

#define	FFTW_DATA_TYPE fftwf_complex


#define space_loop for(long x=0;x<nx;++x)for(long y=0;y<ny;++y)for(long z=0;z<nz;++z) 
#define index_loop for(long p=0;p<nn;p++)

#define CPLX_SQR(__data, __p) ( __data[__p][0]*__data[__p][0] + __data[__p][1]*__data[__p][1] )
#define CPLX_ABS(__data, __p) sqrt( __data[__p][0]*__data[__p][0] + __data[__p][1]*__data[__p][1] )
#define CPLX_PHASE(__data, __p) atan2( __data[__p][1], __data[__p][0] )



class cFFTWdata {	
	
public:
	cFFTWdata();
	cFFTWdata(long);
	~cFFTWdata();
	

	void create(long);
	void create(long, long, long);


	void	createFFTWplan(void);
	void	createFFTWplan(int);
	
	void	speedTest(int);

	long	element(long, long, long);
	
	void	fft(int);

	
public:
	long			nx,ny,nz,nn;
	fftwf_complex	*data;
	
	
private:
	fftwf_plan		plan, iplan;
	
	
};
